package BackTrack.Medium;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class LC0078 {
    List<List<Integer>> result = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {
        result.add(new LinkedList<>());
        innerRecursive(nums, 0, new LinkedList<>());

        return result;
    }

    private void innerRecursive(int[] nums, int start, LinkedList<Integer> path) {
        for (int i = start; i < nums.length; i++) {
            path.addLast(nums[i]);
            result.add(new LinkedList<>(path));
            if (i < nums.length - 1) innerRecursive(nums, i + 1, path);
            path.removeLast();
        }
    }
}
